package handlers

import (
	"go.uber.org/zap"
	"venus/conf"
	"venus/service/sv_tcp/znet"
	"venus/service/sv_tcp/znet/zpb"
	"venus/util/zlog"
	"venus/util/zmisc"
)

// C2GEnterGame 玩家进入游戏
func C2GEnterGame(request *znet.Request) int {
	zlog.Debug("C2GEnterGame")

	zlog.Debug("C2GEnterGame", zap.Int("GetGoroutineID", zmisc.GetGoroutineID()))

	req := &zpb.C2GEnterGame{}
	rsp := &zpb.G2CEnterGame{}
	if !request.GetPb(req) {
		return 1
	}

	player, hasPlayer := GetPLayer(request)
	if !hasPlayer {
		return request.Send(rsp, conf.EProtocolResult请先登录)
	}

	rsp.InfoBase = player.InfoBase()
	rsp.InfoMisc = player.InfoMisc()

	return request.SendSuccess(rsp)
}
